<?php
/**
 * Created by PhpStorm.
 * User: 技术员专用
 * Date: 2019/3/25
 * Time: 15:05
 */
class Server{
    const PORT=8811;

    public function port(){
        $shell='netstat -anp 2>/dev/null| grep 8811 |grep LISTEN | wc -l';//wc 多少行
        $result=shell_exec($shell);
        echo $result;
        if ($result!=1){
            echo 'go die'.PHP_EOL;
        }else{
            echo 'no die'.PHP_EOL;
        }
    }
}
swoole_timer_tick(2000,function ($timer_id){
    (new Server())->port();
});
//$server=new Server();
//$server->port();